{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_star:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Star Coordinate Plot\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Star Coordinate Plot maps a higher dimensional space with a non-linear function to two dimensions. Compared to Radviz, points can be outside of the circle.\n",
    "\n",
    "Let us visualize some test data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.problems import get_problem\n",
    "from pymoo.util.ref_dirs import get_reference_directions\n",
    "\n",
    "ref_dirs = get_reference_directions(\"uniform\", 6, n_partitions=5)\n",
    "F = get_problem(\"dtlz1\").pareto_front(ref_dirs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A simple Star Coordinate Plot plot with points can be created by:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.visualization.star_coordinate import StarCoordinate\n",
    "\n",
    "StarCoordinate().add(F).show()"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "The plot can be further customized by supplying a `title`, `label`, and by using other plotting directives from matplotlib. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "plot = StarCoordinate(title=\"Optimization\",\n",
    "                      legend=(True, {'loc': \"upper left\", 'bbox_to_anchor': (-0.1, 1.08, 0, 0)}),\n",
    "                      labels=[\"profit\", \"cost\", \"sustainability\", \"environment\", \"satisfaction\", \"time\"],\n",
    "                      axis_style={\"color\": \"blue\", 'alpha': 0.7},\n",
    "                      arrow_style={\"head_length\": 0.015, \"head_width\": 0.03})\n",
    "plot.add(F, color=\"grey\", s=20)\n",
    "plot.add(F[65], color=\"red\", s=70, label=\"Solution A\")\n",
    "plot.add(F[72], color=\"green\", s=70, label=\"Solution B\")\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### API"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. autoclass:: pymoo.visualization.star_coordinate.StarCoordinate\n",
    "    :noindex:"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
